#include "../src/NetworkForwardInterface.hpp"
#include "../src/NetworkServer.hpp"
#include <unistd.h>

static NetworkServer* ptrServer=nullptr;
static NetworkForwardInterface* ptrFroward=nullptr;

long RecordID=0;

std::tuple<bool,long> GetRecordStatus()
{
  return std::make_tuple<>(ptrFroward->GetRecordStatus(),RecordID);
}

void StartRecord(long task_id,long stu_id)
{
  ptrFroward->StartRecord(task_id,stu_id);
}

void StopRecord()
{
  ptrFroward->StopRecord();
}

bool CheckStuExist(long id)
{
  return ptrFroward->CheckStudentExists(id);
}

std::string GetStuInf(long id)
{
  return ptrFroward->GetStudentInfo(id);
}

void TerminalConnectChange(bool status)
{
  ptrFroward->MobileConnectChange(status);
}

long CreateTask(const std::string& task_name)
{
  return ptrFroward->CreateTask(task_name);
}

int main()
{
  ptrServer=new NetworkServer;
  ptrFroward=new NetworkForwardInterface;

  ptrServer->funcGetRecordStatus=GetRecordStatus;
  ptrServer->funcStartRecord=StartRecord;
  ptrServer->funcStopRecord=StopRecord;
  ptrServer->funcCheckStuExists=CheckStuExist;
  ptrServer->funcGetStudentInf=GetStuInf;
  ptrServer->funcCreateTask=CreateTask;
  ptrServer->funcTerminalConnectChange=TerminalConnectChange;

  ptrServer->Boot();
  ptrFroward->Boot();

  while(sleep(10)==0) ;
  
  delete ptrServer;
  delete ptrFroward;
}
